﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
//2 thu vien duoc them vao
using Subgurim.Controles;
using System.Configuration;

public partial class _Default : System.Web.UI.Page 
{
    protected string fulladdress;
    public Truycapdulieu truycapdl = new Truycapdulieu();
    protected void Load_HCMcity()
    {
        fulladdress = "Việt Nam";
        string skey = ConfigurationManager.AppSettings["googlemaps.subgurim.net"];
        GeoCode geocode;
        geocode = GMap1.getGeoCodeRequest(fulladdress);
        

        //lấy vĩ độ và kinh độ
        var glatlng = new Subgurim.Controles.GLatLng(geocode.Placemark.coordinates.lat, geocode.Placemark.coordinates.lng);

        //Load google maps
        //var glatlng = new Subgurim.Controles.GLatLng(10.9081311(Vĩ độ), 106.6543439(Kinh độ));
        GMap1.setCenter(glatlng, 6, Subgurim.Controles.GMapType.GTypes.Normal);

        // Chú thích vị trí tìm được
        var oMarker = new Subgurim.Controles.GMarker(glatlng);
       

        //Bản đồ thu nhỏ zoom
        //GMap1.addControl(new GControl(GControl.preBuilt.GOverviewMapControl));

        //Thanh Zoom
        //GMap1.addControl(new GControl(GControl.preBuilt.LargeMapControl));
        GMap1.addControl(new GControl(GControl.preBuilt.LargeMapControl3D));
        
        //Style Maps
        GMap1.addControl(new GControl(GControl.preBuilt.MapTypeControl));
        //GMap1.addControl(new GControl(GControl.preBuilt.HierarchicalMapTypeControl));

        //GMap1.addControl(new GControl(GControl.preBuilt.NavLabelControl));

        //Cho biet khoang cach Góc trái
        GMap1.addControl(new GControl(GControl.preBuilt.ScaleControl));

        //Thanh di chuyển t,p,t,dưới.
        //GMap1.addControl(new GControl(GControl.preBuilt.SmallMapControl));

        //zoom out va zoom in
        //GMap1.addControl(new GControl(GControl.preBuilt.SmallZoomControl3D));
        
        //Document note

        GInfoWindow window = new GInfoWindow(oMarker, fulladdress, true);
        GMap1.addInfoWindow(window);
        
    }
  
    protected void Page_Load(object sender, EventArgs e)
    {
        Load_HCMcity();
        //Label1.Text = DropDownList1.SelectedValue.ToString();
    
       
    }
    //protected void Button1_Click(object sender, EventArgs e)
    //{
    //    string skey = ConfigurationManager.AppSettings["googlemaps.subgurim.net"];
    //    GeoCode geocode;
    //    //fulladdress = string.Format("{0}.{1}.{2}", TextBox1.Text, TextBox2.Text, TextBox3.Text);
        
    //    geocode = GMap1.getGeoCodeRequest(fulladdress);
    //    ////10.9081311,106.6543439
    //    var glatlng = new Subgurim.Controles.GLatLng(geocode.Placemark.coordinates.lat, geocode.Placemark.coordinates.lng);
    //    GMap1.setCenter(glatlng,12, Subgurim.Controles.GMapType.GTypes.Normal);
    //    var oMarker = new Subgurim.Controles.GMarker(glatlng);
    //    GMap1.addGMarker(oMarker); 
    //    GInfoWindow window = new GInfoWindow(oMarker,fulladdress , true);
    //    GMap1.addInfoWindow(window);
    //}

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList2.DataSource = truycapdl.TaoBang("Select ID, PhanLoai From PhanLoai Where ID_LV='" + DropDownList1.SelectedValue.ToString() + "'");
        DropDownList2.DataValueField = "ID";
        DropDownList2.DataTextField = "PhanLoai";
        DropDownList2.DataBind();
        
    }
}